<template>
  <div>
      <title-panel/>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>厂内耳标号</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.earLabelNo }}
        </div>
      </div>
    </van-cell>
     <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>畜禽标识编号</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.preventionNo }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>记录日期</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.recordDate && list.recordDate.substring(0, 10) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%"><span style="color:#FF3B30;">*</span>体重 (kg)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.weight && list.weight.toFixed(1) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%"><span style="color:#FF3B30;">*</span>体高 (cm)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.height && list.height.toFixed(1) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%">体斜长 (cm)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.obliqueLength && list.obliqueLength.toFixed(1) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%">十字部高 (cm)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.crossHeight && list.crossHeight.toFixed(1) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%">胸围 (cm)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.bustSize && list.bustSize.toFixed(1) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 40%">官围 (cm)</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.tubeSize && list.tubeSize.toFixed(1) }}
        </div>
      </div>
    </van-cell>


    <div class="m-b-10 shop">
      <div class="flex-between bottom content font-14 line-height-2">
        <div
          class="col-8686 text-center footerImg"
          @click="goCompile"
          style="width: 50%"
        >
          <img src="../../assets/img/bianji.png" alt="" />
          编辑
        </div>
        <div
          class="col-8686 text-center footerImg"
          @click="deleteContent"
          style="width: 50%"
        >
          <img src="../../assets/img/shanchu.png" alt="" />
          删除
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  Form,
  Field,
  Calendar,
  RadioGroup,
  Radio,
  Dialog,
  Toast,
  DatetimePicker,
  Picker,
  Button,
  Icon,
  Cell,
  Popup,
  Image,
} from "vant";
import dayjs from "dayjs";
// import {
//   commonService,
//   buyProcessService,
//   standardizeService,
// } from "@/services";
import UploadImg from "@/components/uploadImg";
import TitlePanel from "@/components/titlePanel";
import { getValue, setValue, setObject } from "@/utils/auth";
import { postHandle, getHandle } from "@/api";
export default {
  components: {
    UploadImg,
    TitlePanel,
    [Form.name]: Form,
    [Field.name]: Field,
    [Calendar.name]: Calendar,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [Picker.name]: Picker,
    [DatetimePicker.name]: DatetimePicker,
    [Button.name]: Button,
    [Icon.name]: Icon,
    [Popup.name]: Popup,
    [Toast.name]: Toast,
    [Cell.name]: Cell,
    [Dialog.Component.name]: Dialog.Component,
    [Image.name]: Image,
    [Dialog.name]: Dialog,
  },
  data() {
    return {
      list: [],
      imgs: "",
      fileInfoList: [],
      contentObj: {},
      flag: true,
      objGlobal: {
        id: "",
        loginUserId: "",
        tenantCode: "",
        productBatchId: "",
        token: "",
      },
    };
  },
  created() {
    this.getViewData()

    // this.$bridge.register(
    //   "getData",
    //   (loginUserId, tenantCode, token, productBatchId, id, loginName, type) => {
    //     // 请加上自己的事件列表事件
    //     this.objGlobal.productBatchId = productBatchId || "";
    //     this.objGlobal.id = id || "";
    //     this.objGlobal.loginName = loginName || "";
    //     this.objGlobal.tenantCode = tenantCode || "";
    //     this.objGlobal.loginUserId = loginUserId || "";
    //     setValue("allToken", token);
    //     this.initialize();
    //   }
    // );
  },
  mounted() {},
  methods: {
    // 查看页面数据请求
    getViewData() {
      getHandle(`/agri/api/yzbzh/growRecord/queryDetail/${getValue('grow-view-id')}`).then(res => {
        console.log(res);
        this.list = res.data
      })
    },
    getContent() {},
    goCompile() {
      this.$bridge.call("editGrowthRecord");
    },
    initialize() {

      getHandle(
        `/ccyt/api/bzh/farmOperation/queryDetail/${this.objGlobal.id}?loginUserId=${this.objGlobal.loginUserId}&tenantCode=${this.objGlobal.tenantCode}`
      ).then((res) => {
        this.contentObj = res.data;
        this.imgs = res.data.operationImgs;
        this.fileInfoList = res.data.operationImgs.split(",");
      });
    },
    beforeClose(action, done) {
      if (action === "confirm") {
        setTimeout(() => {
          postHandle(
            `/agri/api/yzbzh/growRecord/delete/${getValue('grow-view-id')}`,
          ).then((res) => {
            if (res.status == "0") {
              this.$toast(res.msg);
              done();
              this.$bridge.call('base.closePage')
            } else {
              this.$toast(res.msg);
              done();
            }
          });
        }, 1000);
      } else {
        done();
      }
    },
    deleteContent() {
      Dialog.confirm({
        title: "提示",
        message: "确定要删除吗",
        beforeClose: this.beforeClose,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.van-cell {
  line-height: 40px;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  line-height: 2em;
}
.m-r-10 {
  margin-right: 10px;
}
.line-text-out {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}
.col-1b1b {
  color: #1b1b1b;
}
.col-8686 {
  color: #868686;
}
::v-deep .van-cell {
  border-bottom: none;
}
.imgstyle::after {
  content: "";
  width: 100px;
}
.footerImg {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #37b5b5;
  > img {
    width: 22px;
    height: 22px;
  }
}
.shop .bottom {
  position: fixed;
  bottom: 0;
  height: 68px;
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  padding: 8px 10px 8px 14px;
  box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bthStyle {
  width: 56px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid #2871fe;
}
.addbtn{
    width: 50px;
    height: 24px;
    font-size: 13px;
    padding: 0;
    margin-top: 2px;
}
</style>
